package com.nenglai.admin.config;

import com.nenglai.admin.handler.AuthenticationInterceptor;
import com.nenglai.admin.modular.system.service.ReportAdminService;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author kongdehui
 * @date 2021/04/20 20:59
 **/
@Configuration
@AllArgsConstructor
public class InterceptionConfig implements WebMvcConfigurer {

    private final ReportAdminService adminService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor())
                .addPathPatterns("/backend/**")
                .addPathPatterns("/resource/**"); // 拦截所有请求
    }

    public AuthenticationInterceptor authenticationInterceptor() {
        return new AuthenticationInterceptor(adminService);
    }


}
